package com.atguigu.gulimall.search.controller;

import com.atguigu.common.utils.R;
import com.atguigu.gulimall.search.service.MallSearchService;
import com.atguigu.gulimall.search.vo.SearchParam;
import com.atguigu.gulimall.search.vo.SearchResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@RequestMapping("/search/item")
@RestController
public class SearchController {
    @Resource
    private MallSearchService mallSearchService;

    /**
     * 搜索商品列表
     * @param searchParam
//     * @param model
     * @param request
     * @return
     */
    @GetMapping("/itemList")
    public R getList(SearchParam searchParam, HttpServletRequest request){
        SearchResult res=mallSearchService.search(searchParam);
        return R.ok().put("data",res);

    }
}
